package com.bmit.clusterspring.mapper;

import com.bmit.clusterspring.model.OuterLog;
import com.bmit.clusterspring.model.OuterLogExample;

import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface OuterLogMapper {
    @SelectProvider(type = OuterLogSqlProvider.class, method = "countByExample")
    long countByExample(OuterLogExample example);

    @DeleteProvider(type = OuterLogSqlProvider.class, method = "deleteByExample")
    int deleteByExample(OuterLogExample example);

    @Delete({
            "delete from outer_log",
            "where log_id = #{logId,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long logId);

    @Insert({
            "insert into outer_log (log_id, ip_address, ",
            "run_time, FMI, RI, ",
            "JC, gmt_create)",
            "values (#{logId,jdbcType=BIGINT}, #{ipAddress,jdbcType=CHAR}, ",
            "#{runTime,jdbcType=DOUBLE}, #{fmi,jdbcType=DOUBLE}, #{ri,jdbcType=DOUBLE}, ",
            "#{jc,jdbcType=DOUBLE}, #{gmtCreate,jdbcType=TIMESTAMP})"
    })
    int insert(OuterLog record);

    @InsertProvider(type = OuterLogSqlProvider.class, method = "insertSelective")
    int insertSelective(OuterLog record);

    @SelectProvider(type = OuterLogSqlProvider.class, method = "selectByExample")
    @Results({
            @Result(column = "log_id", property = "logId", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "ip_address", property = "ipAddress", jdbcType = JdbcType.CHAR),
            @Result(column = "run_time", property = "runTime", jdbcType = JdbcType.DOUBLE),
            @Result(column = "FMI", property = "fmi", jdbcType = JdbcType.DOUBLE),
            @Result(column = "RI", property = "ri", jdbcType = JdbcType.DOUBLE),
            @Result(column = "JC", property = "jc", jdbcType = JdbcType.DOUBLE),
            @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP)
    })
    List<OuterLog> selectByExample(OuterLogExample example);

    @Select({
            "select",
            "log_id, ip_address, run_time, FMI, RI, JC, gmt_create",
            "from outer_log",
            "where log_id = #{logId,jdbcType=BIGINT}"
    })
    @Results({
            @Result(column = "log_id", property = "logId", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "ip_address", property = "ipAddress", jdbcType = JdbcType.CHAR),
            @Result(column = "run_time", property = "runTime", jdbcType = JdbcType.DOUBLE),
            @Result(column = "FMI", property = "fmi", jdbcType = JdbcType.DOUBLE),
            @Result(column = "RI", property = "ri", jdbcType = JdbcType.DOUBLE),
            @Result(column = "JC", property = "jc", jdbcType = JdbcType.DOUBLE),
            @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP)
    })
    OuterLog selectByPrimaryKey(Long logId);

    @UpdateProvider(type = OuterLogSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") OuterLog record, @Param("example") OuterLogExample example);

    @UpdateProvider(type = OuterLogSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") OuterLog record, @Param("example") OuterLogExample example);

    @UpdateProvider(type = OuterLogSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(OuterLog record);

    @Update({
            "update outer_log",
            "set ip_address = #{ipAddress,jdbcType=CHAR},",
            "run_time = #{runTime,jdbcType=DOUBLE},",
            "FMI = #{fmi,jdbcType=DOUBLE},",
            "RI = #{ri,jdbcType=DOUBLE},",
            "JC = #{jc,jdbcType=DOUBLE},",
            "gmt_create = #{gmtCreate,jdbcType=TIMESTAMP}",
            "where log_id = #{logId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(OuterLog record);

    @Select({
            "select fmi",
            "from outer_log"
    })
    @Results({
            @Result(column = "fmi", property = "fmi", jdbcType = JdbcType.DOUBLE),
    })
    List<Double> getFMIs();

    @Select({
            "select ri",
            "from outer_log"
    })
    @Results({
            @Result(column = "ri", property = "ri", jdbcType = JdbcType.DOUBLE),
    })
    List<Double> getRIs();

    @Select({
            "select jc",
            "from outer_log"
    })
    @Results({
            @Result(column = "jc", property = "jc", jdbcType = JdbcType.DOUBLE),
    })
    List<Double> getJCs();
}